package com.bafa.front;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.bafa.dbcache.LeagueCache;
import com.bafa.exceptions.ErrorException;
import com.bafa.objects.PageBean;
import com.bafa.objects.season.Season;
import com.bafa.objects.team.Team;
import com.bafa.objects.TeamSeason;
import com.bafa.objects.team.TeamSeasonStats;
import com.bafa.services.RetrieveServices;

public class DisplayTeamSeasonRecordServlet extends DaddyServlet {

	@Override
	public void doEvent(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException, ErrorException {
		Team team = RetrieveServices.getTeam(request.getParameter("TeamId"));
		Season season = RetrieveServices.getSeason(request.getParameter("SeasonId"));
		TeamSeasonStats teamseason = (TeamSeasonStats)team.getStats().getSeasonStats().get(new Integer(request.getParameter("SeasonId")).intValue());
		pageBean = new PageBean((PageBean)LeagueCache.getPages().get("teamseason"));
		String pageHeader = pageBean.getPageheader().replaceAll("<>",team.getName()+" "+season.getName()+" "+season.getYear()+" "+(season.isLeague()?"League":"Cup"));
		pageBean.setPageheader(pageHeader);
		request.setAttribute("Team",team);
		request.setAttribute("TeamSeason",teamseason);
	}
	
}
